/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package ui.widget;

import java.awt.AlphaComposite;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;

public class CloseBtn extends CommonStyleBtn {
	public CloseBtn() {
		setOpaque(false);
		setText("X");
	}

	@Override
	protected void paintComponent(Graphics g) {
		Graphics2D g2d = (Graphics2D) g.create();
		int h = getHeight();
		int w = getWidth();
		Color c = Color.GRAY;
		if (isEnter) {
			c = Color.red;
		}
		g2d.setColor(c);
		g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0));
		g2d.fillRect(0, 0, w, h);
		g2d.setColor(c);
		g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
		BasicStroke bs = new BasicStroke(1.5f);
		g2d.setStroke(bs);
		g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f));
		int x1 = 8, y1 = 8, x2 = w - 4, y2 = h - 8;
		g2d.drawLine(x1, y1, x2, y2);
		g2d.drawLine(x2, y1, x1, y2);
		g2d.dispose();
	}
}
